<!-- 订单消息通知页 -->
<template>
	<view class="body">
		<view class="systemlist">
			<view class="listcard" v-for="(item,index) in systemList" :key="index" @click="systemclick(index)">
				<!-- 消息标题 -->
				<view class="title">
					<text>订单信息通知</text>
				</view>
				<!-- 是否已读标记 -->
				<view class="flgae" v-if="! item.read">
				</view> 
				<!-- 系统内容 -->
				<view class="content">
					<text class="content-text" style="color: #000000;">内容:</text>
					<text style="margin-left: 20rpx;">{{item.messagecontent}}</text>
				</view>
				<view class="issueUser">
					<text>订单系统:</text>
				</view>
				<view class="createTime">
					<text>{{item.createTime}}</text> 
				</view>
			</view>
		</view>
		<view class="loading" >
			<u-loadmore :status="status" :line="line" :nomoreText="nomoreText" /> 
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				systemList:[],
				status:"loading",
				nomoreText:"没有更多了",
			}
		},
		created(){
			if( uni.getStorageSync("ordermsg")){
				var list = JSON.parse(uni.getStorageSync("ordermsg"))
				this.systemList = list
			}
			this.status = "nomore"
		},
		methods:{
			systemclick(index){
				console.log(index)
				var data = {}//传递的数据
				//标记点击的为已读
				for(var i = 0;i< this.systemList.length;i++){
					if(i == index){
						data= this.systemList[i]
						if( this.systemList[i].read == false){
							this.systemList[i].read = true
							var T = uni.getStorageSync("tabbar")
							uni.setStorageSync("tabbar", T - 1)
						}
					}
				}
				uni.setStorageSync("ordermsg",JSON.stringify(this.systemList))
				//设置tabbar
				var num = uni.getStorageSync("tabbar")
				if(num <= 0){
					uni.removeTabBarBadge({
						index:1 
					})
				}
				uni.setTabBarBadge({ //显示数字
					index: 1, //tabbar下标
					text: ""+ num,//数字
					success() {
					},
					fail(e){ 
					}
				})
			},
		},
	}
</script>

<style>
	@import url('../static/css/componentsCss/ordermsg/index.css');
</style>